﻿@model StackExchange.DataExplorer.Models.User
@using StackExchange.DataExplorer
@using StackExchange.DataExplorer.Helpers
@using StackExchange.DataExplorer.ViewModel
@{
    this.SetPageTitle("User " + Model.Login + " - Stack Exchange Data Explorer");
    bool isCurrentUser = Model.Id == Current.User.Id;
}

<div id="profile">
    <table class="vcard">
        <tr>
            <td style="vertical-align:top; width:170px;">
                <table>
                    <tr>
                        <td style="padding:20px 20px 8px 20px;">
                            @Html.Raw(Model.Gravatar(128))
                        </td>
                    </tr>
                </table>
            </td>
            <td style="vertical-align:top; width:350px;>
                @if (isCurrentUser || Current.User.IsAdmin)
                {
                    <div style="float:right; margin-top: 19px; margin-right: 4px;">
                        <a href="/users/edit/@Model.Id">edit</a>
                        @if (isCurrentUser)
                        {
                            <span class="lsep">|</span>
                            <a href="/account/login/" title="overwrite your primary openid by logging in with a new openid">change openid</a>
                        }
                    </div>
                }
                <h2 style="margin-top:20px;">Registered User</h2>
                <table class="user-details">
                    <tr>
                        <td>member for</td>
                        <td><span class="cool" title="@Model.CreationDate">@((DateTime.UtcNow - Model.CreationDate).Value.TimeTaken())</span></td>
                    </tr>
                    <tr>
                        <td>seen</td>
                        <td><span class="@Model.LastSeenDate.Temperature()">@Html.Raw(Model.LastSeenDate.ToRelativeTimeSpan())</span></td>
                    </tr>
                    @if (isCurrentUser || (Current.User != null && Current.User.IsAdmin))
                    {
                        <tr>
                            <td>openid</td>
                            <td><div class="no-overflow">@Model.UserOpenIds[0].OpenIdClaim</div></td>
                        </tr>
                    }
                    @if (Model.Website != null && Model.Website.Length > 4)
                    {
                        <tr>
                            <td>website</td>
                            <td><div class="no-overflow"><a href="http://@Model.Website" rel="me" class="url">@Model.Website</a></div></td>
                        </tr>
                    }
                    <tr>
                        <td>location</td>
                        <td class="label adr">@Model.Location</td>
                    </tr>
                    <tr>
                        <td>age</td>
                        <td>@Model.Age</td>
                    </tr>
                </table>
            </td>
            <td style="width:390px;">
                <div id="user-about-me" class="note">@Html.Raw(Model.SafeAboutMe)</div>
                @if (false) {
                    <div class="summaryinfo">
                        last activity: @Model.LastActivityDate.ToRelativeTime() from this ip address
                    </div>
                }
            </td>
        </tr>
    </table>

    @Html.Partial("SubHeader", ViewData["UserQueryHeaders"])
    <ul class="querylist">
        @foreach (QueryExecutionViewData query in ViewData["Queries"] as IEnumerable<QueryExecutionViewData>)
        {
            <li>
                <a title="@query.Description" href="@query.Url">@query.Name</a>
            </li>
        }
    </ul>
    @if (ViewData["EmptyMessage"] != null)
    {
        <h3>@ViewData["EmptyMessage"]</h3>
    }
    
    @UIHelper.PageNumber(ViewData["Href"].ToString() + "&page=-1", (PagedList<QueryExecutionViewData>)ViewData["Queries"], "pager")
   
    <div class="clear"></div>
</div>